home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / ab20 / unarced / graphics / anim / displayanim0.c < prev    next >
C/C++ Source or Header  |  1995-03-17  |  5KB  |  180 lines

  1.  
  2. /* displayanim0.c
  3.  *
  4.  */
  5.  
  6. #include "intuall.h"
  7. #include <workbench/startup.h>
  8. #include "libraries/dos.h"
  9. #include "libraries/dosextens.h"
  10. #include "ilbm.h"
  11. #include "readpict.h"
  12. #include "stdio.h"
  13. #include "functions.h"
  14.  
  15. /* For WorkBench startup */    
  16. extern struct WBStartup *WBenchMsg;
  17. BOOL   fromWB;
  18. struct FileLock *startLock, *newLock;
  19.  
  20. LONG file;
  21. extern long marktime;
  22. static ILBMFrame iframe;
  23. extern struct Preferences *Prefs;
  24. int loopplay,continuousplay;
  25. extern int ScreenNTSC;
  26.  
  27. struct IntuitionBase *IntuitionBase;
  28. struct GfxBase       *GfxBase;
  29. struct IconBase      *IconBase;
  30. struct DosBase       *DosBase;
  31. extern struct View   *graphics;
  32. /* ================================================ */
  33.  
  34. LONG OpenArg(argc,argv)
  35. int argc;
  36. char **argv;
  37. {
  38.    char *filename;
  39.    struct WBArg    *arg;  
  40.    int i,j;
  41.    char  *str;
  42.  
  43.    j = 0;
  44.    fromWB = (argc==0) ? TRUE : FALSE;
  45.    if((argc>1)&&(*argv[1] != '?')) {  /* Passed filename via command line  */
  46.       for (i=1;i<argc;i++) {
  47.          str = argv[i];
  48.          if (*str == '-') {
  49.             while (*++str) {
  50.                switch (*str) {
  51.                   case 'l':
  52.                   case 'L':
  53.                      loopplay = 0;
  54.                      while (*++str) {
  55.                         loopplay = (loopplay * 10) + (*str - '0');
  56.                      }
  57.                      --str;
  58.                      if (loopplay <= 0) loopplay = 10000;
  59.                      break;
  60.                   case 'c':
  61.                   case 'C':
  62.                      continuousplay = 0;
  63.                      while (*++str) {
  64.                         continuousplay = (continuousplay * 10) + (*str - '0');
  65.                      }
  66.                      --str;
  67.                      if (continuousplay <= 0) continuousplay = 10000;
  68.                      break;
  69.                   default:
  70.                      printf("'%c' bad option\n",*str);
  71.                      break;
  72.                }
  73.             }
  74.          }
  75.          else {
  76.             if (j) {
  77.                puts("Only one file may be specified");
  78.                exit(1L);
  79.             }
  80.             j = i;
  81.          }
  82.       }
  83.    }
  84.    else if ((argc==0)&&(WBenchMsg->sm_NumArgs > 1)) {
  85.       arg = WBenchMsg->sm_ArgList;
  86.       arg++;
  87.       filename   = (char *)arg->wa_Name;
  88.       newLock    = (struct FileLock *)arg->wa_Lock;
  89.       startLock  = (struct FileLock *)CurrentDir(newLock);
  90.       return (Open(filename,(long)MODE_OLDFILE));
  91.    }
  92.    if (j == 0) {
  93.       puts("Usage: 'DisplayANIM [-L#] [-C#] filename");
  94.       puts("            -L#   non-continuous loop play");
  95.       puts("                  # is optional no. of times to loop");
  96.       puts("                  default is 10000 loops");
  97.       puts("            -C#   continuous loop play");
  98.       puts("                  # is optional no. of times to loop");
  99.       puts("                  default is 10000 loops");
  100.       GoodBye("T.T.F.N."); /* contrary to many people's concerns, this is
  101.                               not an obscure error message.  For those not
  102.                               already familiar with Winnie the Pooh, this
  103.                               is the famous parting message by Tigger which
  104.                               stands for "Ta Ta For Now".  There have even
  105.                               been inquiries to the product support people
  106.                               at Aegis regarding this cryptic message. */
  107.    }
  108.    return (Open(argv[j],(long)MODE_OLDFILE));
  109. }
  110.  
  111. _abort()
  112. {
  113.    int i;
  114.  
  115.    DBCloseGraphics();
  116.    puts("*** User Abort ***");
  117.   
  118.    ClosePreLoadIFF();
  119.    if (Prefs) FreeMem(Prefs,(long)sizeof(struct Preferences));
  120.    for (i=0;i<2;i++) DBCloseBuffer(i);
  121.    if (GfxBase)       CloseLibrary(GfxBase);
  122.    if (IntuitionBase) CloseLibrary(IntuitionBase);
  123.    if (DosBase)       CloseLibrary(DosBase);
  124.  
  125.    exit(1);
  126. }
  127.  
  128. GoodBye(msg)
  129. char *msg;
  130. {
  131.    int i;
  132.  
  133.    DBCloseGraphics();
  134.    puts(msg);
  135.   
  136.    ClosePreLoadIFF();
  137.    if (Prefs) FreeMem(Prefs,(long)sizeof(struct Preferences));
  138.    for (i=0;i<2;i++) DBCloseBuffer(i);
  139.    if (GfxBase)       CloseLibrary(GfxBase);
  140.    if (IntuitionBase) CloseLibrary(IntuitionBase);
  141.    if (DosBase)       CloseLibrary(DosBase);
  142.  
  143.    exit(0);
  144. }
  145.  
  146. void OpenLibs()
  147. {
  148.    GfxBase       = NULL;
  149.    IntuitionBase = NULL;
  150.    IconBase      = NULL;
  151.    DosBase       = NULL;
  152.    graphics      = NULL;
  153.  
  154.    if (!(GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",0L)))
  155.       GoodBye("No graphics library");
  156.    if (!(IntuitionBase
  157.        = (struct IntuitionBase *)OpenLibrary("intuition.library",0L)))
  158.       GoodBye("No intuition library");
  159.    if (!(DosBase = (struct DosBase *)OpenLibrary("dos.library",0L)))
  160.       GoodBye("No dos library");
  161. }
  162.  
  163.  
  164. LoadAnim(fname)
  165. char *fname;
  166. {
  167.    IFFP iffp = NO_FILE;
  168.  
  169.    if (file) iffp = PreLoadAnimation(fname,file,&iframe);
  170.    if (newLock != startLock)  CurrentDir(startLock);
  171.    Close(file);
  172.  
  173.    if (iffp != IFF_DONE) {
  174.       printf("Load of %s failed: Iff status %ld\n",fname,(long)iffp);
  175.       return(1);
  176.    }
  177.    return(0);
  178. }
  179.  
  180.